package game.Engine.Entity;

import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.geom.Point2D;

import game.MainController;
import game.display.Animation;
import game.display.Images;

public class Mouse extends Entity {
   public Mouse(double x, double y, Animation gi) {
      super(x, y, gi);
      z = new Double(Integer.MAX_VALUE);
      target = new Point2D.Double();
   }
   private transient Animation anim;
   public void update(long timeElapsed) {
      super.update(timeElapsed);
      Point p = MouseInfo.getPointerInfo().getLocation();
      setX((MainController.displayEngine.vw.getX() + p.x - MainController.getWindowX())/64D - .15625);
      setY((MainController.displayEngine.vw.getY() + p.y - MainController.getWindowY())/64D - .15625);
   }
   private transient Point2D.Double target;
   public Point2D.Double getTarget() {
      target.setLocation(getX() - .5 + .15625, getY() - .5 + .15625);
      return target;
   }

   public void matchWith(Mouse m){
		z = m.getZ();
		x = m.getX();
		y = m.getY();
		dx = m.getVelocityX();
		dy = m.getVelocityY();
		state = m.getState();
   }

   public void updateImage() {
      if(anim == null) {
         gi = anim = Images.CURSOR.image();
      } else {
         gi = anim;
      }
   }
}
